// An highlighted block
<template>
	<view class="content">
		<cu-custom  :isBack="true">
			<block slot="content">修改密码</block>
		  </cu-custom>
		<view class="avatorWrapper">
			<view class="avator">
				<image src="/static/logo.png" mode="aspectFit"></image>
			</view>
		</view>
		<view class="form">
			<view class="inputWrapper">
				<input class="input" type="password" v-model="oddpwd" placeholder="请输入旧密码"/>
			</view>
			<view class="inputWrapper">
				<input class="input" type="password" v-model="pwd" placeholder="请输入新密码"/>
			</view>
			<view class="inputWrapper">
				<input class="input" type="password" v-model="pwds" placeholder="再次输入新密码"/>
			</view>
			<view class="loginBtn" @click="submit">
				<text class="btnValue">修改</text>
			</view>
		</view>
	</view>
</template>

<script>
	import store from '../../store/index.js'
	export default {
		data() {
			return {
				oddpwd:'',
				pwd:'',
				pwds:''
			}
		},
		// components:{
		// 	username(){
		// 		console.log(this.$store.state)
		// 		return this.$store.state.username
		// 	}
		// },
		onLoad() {
			
		},
		methods: {
			submit(){
				//var username = this.$store.state.username
				var oddpwd = this.oddpwd;
				var pwd = this.pwd;
				var pwds = this.pwds;
				console.log(oddpwd);
				console.log(pwd);
				if(oddpwd==""||oddpwd==null){
					uni.showToast({
						title:"请输入旧密码！",
						icon:"none"
					})
				}else if(pwd==""||pwd==null){
					uni.showToast({
						title:"请输入新密码！",
						icon:"none"
					})
				}else if(pwds==""||pwds==null){
					uni.showToast({
						title:"请再次输入新密码！",
						icon:"none"
					})
				}else if(pwd!=pwds){
					uni.showToast({
						title:"两次密码输入不正确！",
						icon:"none"
					})
				}else{
					//var params = {oldPassword:this.oddpwd,password:this.pwds}
					this.$http.post("/sys/v1/updatePassword.do",{
							  oldPassword:oddpwd,password:pwds
							  }).then(res=> {	
								  console.log(res);
									if (res.statusCode == 200) {
										console.log('修改成功!')
										this.$tip.success('修改成功!')
									}else if(res.statusCode == 7001){
										this.$tip.success('原密码不正确！')
									}
									console.log(this.oddpwd);
									console.log(this.pwd);
							}).catch(e=>{
								console.log("请求错误",e)
						});
				}
				
			}
		}
	}
</script>

<style>
	.content {
		background: #fff;
		width: 100vw;
		height: 100vh;
	}
	.avatorWrapper{
		height: 30vh;
		width: 100vw;
		display: flex;
		justify-content: center;
		align-items: flex-end;
	}
	.avator{
		width: 200upx;
		overflow: hidden;
	}
	.avator .img{
		width: 100%
	}
	.form{
		padding: 0 100upx;
	}
	.inputWrapper{
		border:0.5px solid #808080;
		width: 100%;
		height: 80upx;
		background: white;
		border-radius: 20px;
		box-sizing: border-box;
		padding: 0 20px;
		margin-top: 25px;
	}
	.inputWrapper .input{
		width: 100%;
		height: 100%;
		text-align: center;
		font-size: 15px;
	}
	.loginBtn{
		width: 100%;
		height: 80upx;
		background: #77B307;
		border-radius: 50upx;
		margin-top: 50px;
		display: flex;
		justify-content: center;
		align-items: center;
		
	}
	.loginBtn .btnValue{
		color: white;
	}
	.forgotBtn{
		text-align: center;
		color: #EAF6F9;
		font-size: 15px;
		margin-top: 20px;
	}
</style>
